home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 1116.ZIP / TOOLKIT.ARC / DECOM.DOC < prev    next >
Text File  |  1979-12-31  |  4KB  |  96 lines

  1. (*
  2.                        DOCUMENTATION FOR: DECOM.COM
  3. __________________________________________________________________________
  4.  
  5.       DECOM strips the comment lines out of the assembly language code
  6.             file that are written by the CPC Small C compiler (CPC.EXE).
  7.  
  8.       DECOM makes handling of large Small C programs easier, since
  9.             the large *.ASM file that CPC.EXE writes contains all of
  10.             the Small C syntax as comment lines.
  11.  
  12.       DECOM was written so that CPCX.ASM could be made to fit on a
  13.             179 Kbyte-formatted single-sided floppy disk.  Before DECOM
  14.             the file size of CPCX.ASM was 193.3 Kbytes.  After DECOM the
  15.             file size of CPCX.ASM was 141.0 Kbytes (11307 ASM code lines).
  16.             Unfortunately, this did not shorten the assembly time, using
  17.             MASM.
  18.  
  19.       DECOM renames the *.ASM file as *.TMP and tests to see if
  20.             the first character of each line is a semicolon.  If the
  21.             first character is not a semicolon, then the line is
  22.             written to a new *.ASM file.  The *.TMP file is then erased.
  23. __________________________________________________________________________
  24.  
  25. *)
  26.  
  27. PROGRAM DECOM(INPUT,OUTPUT);
  28.  
  29. TYPE SOURCE_CODE      = TEXT;
  30.  
  31. VAR  SOURCE_CODE_IN   : SOURCE_CODE;
  32.      SOURCE_CODE_OUT  : SOURCE_CODE;
  33.      LINE_NUMBER      : STRING[5];
  34.      PROG_NAME_IN     : STRING[12];
  35.      PROG_NAME_OUT    : STRING[12];
  36.      PROG_NAME_TMP    : STRING[12];
  37.      A_LINE_OF_CODE   : STRING[70];
  38.      L1,L2            : INTEGER;
  39.  
  40. PROCEDURE INPUT_SCREEN;
  41.    BEGIN  {INPUT}
  42.       CLRSCR; GOTOXY(33,6); WRITELN('PROGRAM  DECOM');
  43.       GOTOXY(18,8); WRITELN('[to reduce the size of Small C *.ASM files]');
  44.       GOTOXY(21,12); WRITELN('ENTER the name of the file to reduce');
  45.       GOTOXY(28,14); WRITE('--> '); READLN(PROG_NAME_IN);
  46.       {Note: PROG_NAME_IN will already be <= 8 char in length via MS-DOS}
  47.       L1 := POS('.',PROG_NAME_IN); {Check for a filename extension}
  48.       IF L1 > 0 THEN
  49.          BEGIN  {IF}
  50.             PROG_NAME_OUT := COPY(PROG_NAME_IN,1,L1);
  51.             PROG_NAME_TMP := PROG_NAME_OUT + 'TMP';
  52.             PROG_NAME_OUT := PROG_NAME_OUT +'ASM';
  53.          END  {IF}
  54.       ELSE
  55.          BEGIN  {ELSE}
  56.             PROG_NAME_TMP := PROG_NAME_IN + '.TMP';
  57.             PROG_NAME_OUT := PROG_NAME_IN + '.ASM';
  58.          END;  {ELSE}
  59.       GOTOXY(24,18);
  60.       ASSIGN(SOURCE_CODE_IN,PROG_NAME_IN);
  61.       RESET(SOURCE_CODE_IN);
  62.       READLN(SOURCE_CODE_IN,A_LINE_OF_CODE);
  63.       CLOSE(SOURCE_CODE_IN);
  64.    END;  {INPUT}
  65.  
  66. PROCEDURE READ_THEN_STRIP_THEN_REWRITE_THE_CODE;
  67.    BEGIN  {R-S-RW-C}
  68.       L2 := 0;
  69.       ASSIGN(SOURCE_CODE_IN,PROG_NAME_TMP);
  70.       RESET(SOURCE_CODE_IN);
  71.       ASSIGN(SOURCE_CODE_OUT,PROG_NAME_OUT);
  72.       REWRITE(SOURCE_CODE_OUT);
  73.       WHILE NOT EOF(SOURCE_CODE_IN) DO
  74.          BEGIN  {WHILE}
  75.             READLN(SOURCE_CODE_IN,A_LINE_OF_CODE);
  76.                IF A_LINE_OF_CODE[1] <> ';' THEN
  77.                   BEGIN {IF}
  78.                      WRITELN(SOURCE_CODE_OUT,A_LINE_OF_CODE);
  79.                      L2 := L2 + 1;
  80.                   END; {IF}
  81.          END;  {WHILE}
  82.       CLOSE(SOURCE_CODE_IN);
  83.       CLOSE(SOURCE_CODE_OUT);
  84.    END;  {R-S-RW-C}
  85.  
  86. BEGIN  {MAIN}
  87.    INPUT_SCREEN;
  88.    RENAME(SOURCE_CODE_IN,PROG_NAME_TMP);
  89.    READ_THEN_STRIP_THEN_REWRITE_THE_CODE;
  90.    GOTOXY(1,22);
  91.    WRITELN('                            PROCESSING COMPLETE');
  92.    WRITELN('                         PROGRAM LINE COUNT IS: ',L2);
  93.    WRITELN(' ');
  94.    ERASE(SOURCE_CODE_IN);
  95. END.  {MAIN}
  96.